package com.kaishengit.service;

import java.util.List;

import com.kaishengit.dao.IdeaCommentDao;
import com.kaishengit.dao.IdeaDao;

import com.kaishengit.entity.Idea;
import com.kaishengit.entity.IdeaComment;
import com.kaishengit.entity.UserProject;
import com.kaishengit.util.DateUtil;
import com.kaishengit.util.PkUtil;

public class IdeaService {
	IdeaDao idao=new IdeaDao();
	IdeaCommentDao icDao=new IdeaCommentDao();
	public List<Idea>  findByProjectId(String ProjectId){
		idao.findByProjectId(ProjectId);
		return  idao.findByProjectId( ProjectId );
	}
	
	public void save (String content,String title,UserProject userProject){
		Idea idea=new Idea();
		idea.setContent(content);
		idea.setTitle(title);
		idea.setCreatetime(DateUtil.getNowDateTime());
		idea.setId(PkUtil.getId());
		idea.setProject(userProject.getProject());
		idea.setProjectId(userProject.getProject().getId());
		idea.setUser(userProject.getUser());
		idea.setUserId(userProject.getUser().getId());
		idao.save(idea);
	}
	
	public Idea  findByIdeaId(String IdeaId){
		idao.findByIdeaId(IdeaId);
		return (Idea) idao.findByIdeaId(IdeaId);
	}
	
	public void del (String id){
		idao.del(id);
		
	}
	public void dele(String ideaid){
		
		icDao.dele(ideaid);
	}
	
	
	
	
	
	
	
	
	
	public void Del(String id){
		icDao.Del(id);
		
	}
	public void update(String content,String IdeaCommentId){
		icDao.update(content, IdeaCommentId);
		
	}
	
	public List<IdeaComment> findById(String IdeaId){
		icDao.findById(IdeaId);
		return icDao.findById(IdeaId);
	}
	public IdeaComment findByIdeaCommentId(String IdeaCommentId){
		return icDao.findByIdeaCommentId(IdeaCommentId);
	}
	 public void C_save(String content,String ideaid,UserProject userProject){
		 
		    IdeaComment ic=new IdeaComment();
			ic.setContent(content);
			ic.setCreatetime(DateUtil.getNowDateTime());
			ic.setId(PkUtil.getId());
			ic.setIdeaId(ideaid);
			ic.setUser(userProject.getUser());
			ic.setUserId(userProject.getUser().getId());
			
			icDao.save(ic);
			
			
		 
	 }

}
